package com.cqupt.scanning.system.file.helper;

import java.io.File;

/**
 * 文件操作类
 * @Data: 2021/7/7 22:19
 * @Author: 宋宝梁
 */
public class FileHandler {

    /**
     * 递归删除文件
     * @param dir
     * @return
     */
    public static boolean deleteDir(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (String child : children) {
                boolean success = deleteDir(new File(dir, child));
                if (!success) {
                    return false;
                }
            }
        }
        // 非目录，直接删除
        return dir.delete();
    }
}
